import http from "@/api";
import { ResPage } from "@/api/interface/index";
import { System } from "../../interface/iot";
import { SYSTEM_ID } from "@/config/config";

export const getDictTypeList = (params: System.ReqDictType) => {
	params.systemId = params.systemId || SYSTEM_ID;
	return http.get<ResPage<System.ResDictType[]>>(`/dict/type/find`, params);
};
export const addDictType = (params: System.ResDictType) => {
	params.systemId = params.systemId || SYSTEM_ID;
	return http.post(`/dict/type/add`, params);
};
export const delDictType = (params: System.ResDictType) => {
	return http.post(`/dict/type/remove`, params);
};
export const modDictType = (params: System.ResDictType) => {
	return http.post(`/dict/type/modify`, params);
};

export const getDictList = (params: System.ReqDict) => {
	params.systemId = params.systemId || SYSTEM_ID;
	return http.get<ResPage<System.ResDictType[]>>(`/dict/data/find`, params);
};
export const addDict = (params: System.ResDict) => {
	params.systemId = params.systemId || SYSTEM_ID;
	return http.post(`/dict/data/add`, params);
};
export const delDict = (params: System.ResDict) => {
	return http.post(`/dict/data/remove`, params);
};
export const modDict = (params: System.ResDict) => {
	return http.post(`/dict/data/modify`, params);
};
export const exportDictType = (params: { [key: string]: any }, dictTypeIn?: string) => {
	return http.downloadGet("/dict/type/export?" + dictTypeIn, params, { responseType: "blob" });
};
export const importDictType = (params: FormData) => {
	return http.post(`/dict/type/import`, params);
};

export const exportDictData = (params: { [key: string]: any }, dictTypeIn?: string) => {
	return http.downloadGet("/dict/data/export?" + dictTypeIn, params, { responseType: "blob" });
};
export const importDictData = (params: FormData) => {
	return http.post(`/dict/data/import`, params);
};
